package com.mingchuang.administrator.mingchuang.pile;

import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.TextView;

import com.mingchuang.administrator.mingchuang.R;
import com.mingchuang.administrator.mingchuang.bean.PileInfoBean;

import java.util.List;

/**
 * Created by Administrator on 2016/1/18.
 */
    public class PileAdapter extends BaseAdapter{

    private List<PileInfoBean> list;
    private LayoutInflater inflater = null;


    public PileAdapter(Context context ,List<PileInfoBean> list) {
        this.list = list;
        inflater = LayoutInflater.from(context);
    }


    public void setList(List<PileInfoBean> list){
        this.list = list;
    }





    @Override
    public int getCount() {
        return list.size();
    }

    @Override
    public Object getItem(int position) {
        return null;
    }

    @Override
    public long getItemId(int position) {
        return 0;
    }

    @Override
    public View getView(int position, View convertView, ViewGroup parent) {
        PileInfoBean pile = list.get(position);
        ViewHolder holder;
        if(convertView == null){
            convertView = inflater.inflate(R.layout.pile_item,null);
            holder = new ViewHolder();

            holder.pileName = (TextView) convertView.findViewById(R.id.pile_name);
            holder.testDate = (TextView) convertView.findViewById(R.id.test_date);
            holder.isUpload = (TextView) convertView.findViewById(R.id.is_upload);
            holder.isPic = (TextView) convertView.findViewById(R.id.is_pic);
            holder.isGps = (TextView) convertView.findViewById(R.id.is_gps);
            convertView.setTag(holder);
        }else{
            holder = (ViewHolder) convertView.getTag();

        }


        holder.pileName.setText(pile.getPileName());

        holder.testDate.setText("2015-10-2");

        holder.isUpload.setText(pile.getIsUpload().equals("0")? "未上传":"已上传");
        holder.isPic.setText(pile.getIsPic().equals("0")? "无图":"有图");
        holder.isGps.setText(pile.getIsGps().equals("0")? "无GPS":"有GPS");







        return convertView;
    }


    static class ViewHolder {
        TextView pileName;
        TextView testDate;
        TextView isUpload;
        TextView isPic;
        TextView isGps;





    }



}
